package com.ruoyi.tactics.algorithm;

import com.ruoyi.common.utils.ZodiacCalculator;
import com.ruoyi.tactics.ZodiacResult;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class ThreeZodiacAlgorithm extends AbstractAlgorithm {
    @Override
    public Boolean isWin(ZodiacResult zodiacResult, String... code) {
        ZodiacCalculator zodiacCalculator = new ZodiacCalculator();
        Set<String> zodiacs = new HashSet<>();
        zodiacResult.getPm().forEach(r -> {
            zodiacs.add(zodiacCalculator.getZodiacByAge(r));
        });
        Set<String> codes = new HashSet<>();
        codes.addAll(Arrays.asList(code));
        codes.retainAll(zodiacs);
        return codes.size() >= 3;
    }


    public static void main(String[] args) {
        ThreeZodiacAlgorithm algorithm = new ThreeZodiacAlgorithm();
        ZodiacResult zodiacResult = new ZodiacResult();
        zodiacResult.setPm(Arrays.asList(1,2,3,4,5));
        System.out.println( algorithm.isWin(zodiacResult,"蛇","龙","兔"));
        System.out.println( algorithm.isWin(zodiacResult,"猪","蛇","兔"));


    }
}
